package com.example.musicapi.dao;

import com.example.musicapi.entity.Notice;
import com.example.musicapi.entity.Remark;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface RemarkDao extends JpaRepository<Remark, String> {

    Remark findDataById(String id);

    Page<Remark> findAll(Pageable pageable);

    Page<Remark> findAllById(Pageable pageable, String id);


    @Query("SELECT n FROM Remark n WHERE n.song_id = :key")
    Page<Remark> findBySearch(@Param("key")  String key, Pageable pageable);

    //  根据 key 进行模糊查询的分页方法
    @Query("SELECT n FROM Remark n WHERE n.txt LIKE %:key%")
    Page<Remark> findBySearchTxt(@Param("key")  String key, Pageable pageable);
}
